<!DOCTYPE html>
<html>
  
  <head>
    <meta charset="UTF-8">
    <title>project edit</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="stylesheet" href="/static/super_cmdb/css/font.css">
    <link rel="stylesheet" href="/static/super_cmdb/css/xadmin.css">

  </head>
  
  <body>
    <div class="x-body">
        <form class="layui-form">

          <div class="layui-form-item">
              <label for="name" class="layui-form-label" style="width: 160px;">
                  <span class="x-red">*</span>项目名称
              </label>
              <div class="layui-input-inline" style="width: 400px;">
                  <input type="text" id="name" name="name" required="" lay-verify="required"
                  autocomplete="off" value="{{ project_info.name }}" class="layui-input">
              </div>
          </div>

          <div class="layui-form-item">
              <label for="cloud_project_id" class="layui-form-label" style="width: 160px;">
                  <span class="x-red">*</span>项目云id1
              </label>
              <div class="layui-input-inline" style="width: 400px;">
                  <input type="text" id="cloud_project_id" name="cloud_project_id" required="" lay-verify="required"
                  autocomplete="off" value="{{ project_info.cloud_project_id }}"  class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux">
                  <span class="x-red">*</span>公有云上项目对应的项目id1
              </div>
          </div>
          <div class="layui-form-item">
              <label for="cloud_account_id1" class="layui-form-label" style="width: 160px;">
                  <span class="x-red">*</span>项目云id1关联的云账号
              </label>
              <div class="layui-input-inline" style="width: 400px;">
                  <select id="cloud_account_id1" name="cloud_account_id1">
                        <option value="{{ project_info.cloud_account_id1 }}">关联账号:{{ project_info.cloud_account_id1 }}</option>
                        {% for account in cloud_account_list %}
                            <option value="{{ account.account }}">{{ account.platform }}_{{ account.account }}({{ account.name }})</option>
                        {% endfor %}
                  </select>
              </div>
          </div>
          <div class="layui-form-item">
              <label for="cloud_project_id2" class="layui-form-label"  style="width: 160px;">
                  <span class="x-red">*</span>项目云id2
              </label>
              <div class="layui-input-inline" style="width: 400px;">
                  <input type="text" id="cloud_project_id2" name="cloud_project_id2" required="" lay-verify="required"
                  autocomplete="off" value="{{ project_info.cloud_project_id2 }}"  class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux">
                  <span class="x-red">*</span>公有云上项目对应的项目id2
              </div>
          </div>
          <div class="layui-form-item">
              <label for="cloud_account_id2" class="layui-form-label" style="width: 160px;">
                  <span class="x-red">*</span>项目云id2关联的云账号
              </label>
              <div class="layui-input-inline" style="width: 400px;">
                  <select id="cloud_account_id2" name="cloud_account_id2">
                        <option value="{{ project_info.cloud_account_id2 }}">关联账号:{{ project_info.cloud_account_id2 }}</option>
                        {% for account in cloud_account_list %}
                            <option value="{{ account.account }}">{{ account.platform }}_{{ account.account }}({{ account.name }})</option>
                        {% endfor %}
                  </select>
              </div>
          </div>
          <div class="layui-form-item">
              <label for="cloud_project_id3" class="layui-form-label" style="width: 160px;">
                  <span class="x-red">*</span>项目云id3
              </label>
              <div class="layui-input-inline" style="width: 400px;">
                  <input type="text" id="cloud_project_id3" name="cloud_project_id3" required="" lay-verify="required"
                  autocomplete="off" value="{{ project_info.cloud_project_id3 }}"  class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux">
                  <span class="x-red">*</span>公有云上项目对应的项目id3
              </div>
          </div>
          <div class="layui-form-item">
              <label for="cloud_account_id3" class="layui-form-label" style="width: 160px;">
                  <span class="x-red">*</span>项目云id3关联的云账号
              </label>
              <div class="layui-input-inline" style="width: 400px;">
                  <select id="cloud_account_id3" name="cloud_account_id3">
                        <option value="{{ project_info.cloud_account_id3 }}">关联账号:{{ project_info.cloud_account_id3 }}</option>
                        {% for account in cloud_account_list %}
                            <option value="{{ account.account }}">{{ account.platform }}_{{ account.account }}({{ account.name }})</option>
                        {% endfor %}
                  </select>
              </div>
          </div>
          <div class="layui-form-item">
              <label for="name_en" class="layui-form-label" style="width: 160px;">
                  <span class="x-red">*</span>项目英文名
              </label>
              <div class="layui-input-inline" style="width: 400px;">
                  <input type="text" id="name_en" name="name_en" required="" lay-verify="required"
                  autocomplete="off" value="{{ project_info.name_en }}" class="layui-input">
              </div>
          </div>

          <div class="layui-form-item">
              <label for="describe" class="layui-form-label" style="width: 160px;">
                  <span class="x-red">*</span>工作室
              </label>
              <div class="layui-input-inline">
                  <textarea id="describe" name="describe" style="margin: 0px;width: 400px;height: 40px;">{{ project_info.describe }}</textarea>
              </div>
          </div>

          <div class="layui-form-item">
              <label for="L_repass" class="layui-form-label" style="width: 160px;">
              </label>
              <button  class="layui-btn" lay-filter="edit" lay-submit="">
                  修改
              </button>
          </div>
      </form>
    </div>
    <script type="text/javascript" src="/static/super_cmdb/js/jquery.min.js"></script>
    <script type="text/javascript" src="/static/super_cmdb/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/static/super_cmdb/js/xadmin.js"></script>
    <script type="text/javascript" src="/static/super_cmdb/js/jquery.cookie.js"></script>
        <script>

        $(function () {
            $.ajaxSetup({
                beforeSend:function (xhr,settings) {
                    xhr.setRequestHeader("X-CSRFtoken",$.cookie("csrftoken"));
                }
            })
        });

      layui.use(['form','layer'], function(){
          $ = layui.jquery;
        var form = layui.form
        ,layer = layui.layer;

        //监听提交
        form.on('submit(edit)', function(data){
          console.log(data);
          //发异步，把数据提交给php
            $.ajax({
                    url: "/super_cmdb/project_edit-{{ project_info.id }}/",
                    type: "POST",
                    //data: $('#layui-form').serialize(),
                    data: {
                        "name":$("#name").val(),
                        "cloud_project_id":$("#cloud_project_id").val(),
                        "cloud_account_id1":$("#cloud_account_id1").val(),
                        "cloud_project_id2":$("#cloud_project_id2").val(),
                        "cloud_account_id2":$("#cloud_account_id2").val(),
                        "cloud_project_id3":$("#cloud_project_id3").val(),
                        "cloud_account_id3":$("#cloud_account_id3").val(),
                        "name_en":$("#name_en").val(),
                        "describe":$("#describe").val(),
                        },
                    success: function (data) {
                        console.log($("#cloud_project_id1").val());
                    }
                });

          layer.alert("修改成功", {icon: 6},function () {
              // 获得frame索引
              var index = parent.layer.getFrameIndex(window.name);
              //关闭当前frame
              parent.layer.close(index);
          });
          return false;
        });
      });

  </script>
  </body>

</html>